from django.shortcuts import render
from django.urls import reverse_lazy
from django.views.generic import CreateView, TemplateView, ListView, UpdateView

from assets.models import ProductLine


# todo add_line_auth
class ProductLineListView(ListView):
    template_name = "assets/product_list.html"
    queryset = ProductLine.objects.all().order_by("name")
    context_object_name = "product_obj_list"


class ProductLineCreateView(CreateView):
    """产品线"""
    model = ProductLine
    fields = ["name", "al_name", "sort"]
    success_url = reverse_lazy('product_lines_list')
    template_name = 'assets/product_create.html'

    def form_valid(self, form):
        # todo 重定向到 添加idc(如果idc为空) 或者 添加主机页面
        return super(ProductLineCreateView, self).form_valid(form)


# TODO add_line_auth
class ProductLineUpdateView(UpdateView):
    model = ProductLine
    fields = ["name", "al_name", "sort"]
    success_url = reverse_lazy('product_lines_list')
    template_name = "assets/product_line_update.html"



'''


'''
